Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

blobcacheinfo,test: blobs must be resued when pushing across registry #5153

Merged
merged 1 commit into from
Nov 17, 2023

Conversation

flouthoc
Copy link
Collaborator

@flouthoc flouthoc commented Nov 10, 2023

It seems we try to reuse blobs only for the specified registry, however we can have valid known compressed digests across registry as well following pr attempts to test that use-case where feature was implemented in containers/image#1645


How to manually test this ?

$ skopeo copy docker://registry.fedoraproject.org/fedora-minimal docker://quay.io/fl/test:some-tag
$ buildah pull registry.fedoraproject.org/fedora-minimal
$ buildah tag registry.fedoraproject.org/fedora-minimal quay.io/fl/test
$ buildah push quay.io/fl/test
Getting image source signatures
Copying blob a3497ca15bbf skipped: already exists
Copying config f7e02de757 done
Writing manifest to image destination
Storing signatures

Testing: containers/image#1645

What type of PR is this?

/kind api-change
/kind bug
/kind cleanup
/kind deprecation
/kind design
/kind documentation
/kind failing-test
/kind feature
/kind flake
/kind other

What this PR does / why we need it:

How to verify it

Which issue(s) this PR fixes:

Special notes for your reviewer:

Does this PR introduce a user-facing change?

None

@flouthoc
Copy link
Collaborator Author

@containers/buildah-maintainers @mtrmac PTAL

@flouthoc
Copy link
Collaborator Author

Tests are green.


# Clear local image and c/image's blob-info-cache
run_buildah rmi --all -f
run rm /var/lib/containers/cache/blob-info-cache-v1.sqlite
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The result of this run() isn't checked, and I'd be surprised if it succeeds for non-root users.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nalind New commit addresses this comment.

Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unit tests are frequently timing out, compare 881337e in #5143 .

@test "blobcache: blobs must be reused when pushing across registry" {
start_registry
run_buildah login --tls-verify=false --authfile ${TEST_SCRATCH_DIR}/test.auth --username testuser --password testpassword localhost:${REGISTRY_PORT}
run_buildah pull registry.fedoraproject.org/fedora-minimal
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An ignorant question, is there some mechanism to avoid reaching out to external registries that could be used here? I can see _prefetch, but that seeds c/storage, not a registry, so that seems not directly applicable. Or maybe something like that already works transparently?

Maybe this could, at least, only reach to r.fp.org once:

skopeo copy docker://…fp.org dir:original
buildah pull dir:original
… tag … push
# clean
buildah pull dir:original
… tag … push

(I didn’t actually try running the above.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This SGTM i'll try this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mtrmac Latest commit should address this, Could you PTAL again.

tests/blobcache.bats Outdated Show resolved Hide resolved
tests/blobcache.bats Outdated Show resolved Hide resolved
tests/blobcache.bats Outdated Show resolved Hide resolved
tests/blobcache.bats Outdated Show resolved Hide resolved
tests/blobcache.bats Outdated Show resolved Hide resolved
@flouthoc
Copy link
Collaborator Author

@mtrmac PTAL again

Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test operation LGTM.

(#5153 (comment) is back but I’ll fully defer to repo maintainers on whether it is worth worrying about at all.)

@flouthoc
Copy link
Collaborator Author

The test operation LGTM.

(#5153 (comment) is back but I’ll fully defer to repo maintainers on whether it is worth worrying about at all.)

@mtrmac Does latest commit resolves comment #5153 (comment)

@flouthoc flouthoc requested a review from mtrmac November 17, 2023 06:42
It seems we try to reuse blobs only for the specified registry, however
we can have valid known compressed digests across registry as well
following pr attempts to use that by doing following steps.

* `CandidateLocations2` now processes all known blobs and appends them
  to returned candidates at the lowest priority. As a result when
`TryReusingBlob` tries to process these candidates and if the blobs
filtered by the `Opaque` set by the `transport` fail to match then
attempt is made against all known blobs (ones which do not belong to the
current registry).

* Increase the sample set of potential blob reuse to all known
  compressed digests , also involving the one which do not belong to
current registry.

* If a blob is found match it against the registry where we are
  attempting to push. If blob is already there consider it a `CACHE
HIT!` and reply skipping blob, since its already there.

----

```console
$ skopeo copy docker://registry.fedoraproject.org/fedora-minimal docker://quay.io/fl/test:some-tag
$ buildah pull registry.fedoraproject.org/fedora-minimal
$ buildah tag registry.fedoraproject.org/fedora-minimal quay.io/fl/test
$ buildah push quay.io/fl/test
```

```console
Getting image source signatures
Copying blob a3497ca15bbf skipped: already exists
Copying config f7e02de757 done
Writing manifest to image destination
Storing signatures
```

Testing: containers/image#1645

Signed-off-by: Aditya R <arajan@redhat.com>
@rhatdan
Copy link
Member

rhatdan commented Nov 17, 2023

/approve
/lgtm

Copy link
Contributor

openshift-ci bot commented Nov 17, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: flouthoc, rhatdan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit 6622a7b into containers:main Nov 17, 2023
36 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants